// 云函数入口文件
const cloud = require('wx-server-sdk')
const cheerio  = require('cheerio');
const axios = require('axios');
cloud.init()
const bookliburl = 'http://interlib.sdust.edu.cn/opac/m/search?curlibcode=01000&q='
//下面是获取图片封面请求地址
//http://book-resource.dataesb.com/websearch/metares?glc=U1SD0532017&cmdACT=getImages&type=0&isbns=,7505349252,7030059158,9787564145965,7564100400,9787115504920,9787121342608,9787121273148,7505338404,7505393278,756410239X
// 云函数入口函数
exports.main = async (event, context) => {
  let url = bookliburl+event.searchkey+'&page='+event.page
  return new Promise(function(resolve,reject){
    axios.get(url)
    .then(function (response) {
     // console.log(response);
      let htmldata = response.data;
      $ = cheerio.load(htmldata);
      // $('td em').each(function(index,ele){
      //   // console.log($(this).html())
      // })
     
     
    })
    .catch(function (error) {
      reject(error)
    });
  })
}